package org.hamster.multidropbox.main.model
{
	import flash.filesystem.File;
	import flash.net.URLRequestMethod;
	
	import org.hamster.common.puremvc.proxies.BaseRemoteProxy;
	import org.hamster.common.services.ConfigService;
	import org.hamster.multidropbox.main.vo.AppConfigVO;
	
	public class AppInitProxy extends BaseRemoteProxy
	{
		public static const NAME:String = "AppInitProxy";
		
		public function get configVO():AppConfigVO
		{
			if (ConfigService.instance.configVO == null) {
				return new AppConfigVO();
			} else {
				return ConfigService.instance.configVO as AppConfigVO;
			}
		}
		
		public function AppInitProxy()
		{
			super(NAME, "   123");
		}
		
		public function loadConfig(testMode:Boolean = false):void {
			if (testMode) {
				this.load("xml/config.xml", null, URLRequestMethod.GET);
			} else {
				this.load(File.applicationStorageDirectory + File.separator + "config.xml", null, URLRequestMethod.GET);
			}
		}
		
		override protected function processResultHandler(data:Object):void
		{
			ConfigService.instance.init(data as XML, AppConfigVO);
		}
	}
}